/*    */ package com.engine;
/*    */ 
/*    */ import java.io.FileInputStream;
/*    */ import java.io.FileOutputStream;
/*    */ import java.io.PrintStream;
/*    */ import java.text.SimpleDateFormat;
/*    */ import java.util.Calendar;
/*    */ import java.util.Date;
/*    */ import java.util.Properties;
/*    */ 
/*    */ public class Tools
/*    */ {
/*    */   public static String readprops(String file, String key, String def)
/*    */   {
/*    */     try
/*    */     {
/* 13 */       Properties p = new Properties();
/* 14 */       p.load(new FileInputStream(file));
/* 15 */       return p.getProperty(key);
/*    */     }
/*    */     catch (Exception e) {
/* 18 */       System.out.println(e);
/* 19 */     }return def;
/*    */   }
/*    */ 
/*    */   public static void writeprops(String file, String key, String value)
/*    */   {
/*    */     try {
/* 25 */       Properties p = new Properties();
/* 26 */       p.load(new FileInputStream(file));
/*    */ 
/* 28 */       p.put(key, value);
/* 29 */       FileOutputStream out = new FileOutputStream(file);
/* 30 */       p.store(out, "/* properties updated */");
/*    */     }
/*    */     catch (Exception e) {
/* 33 */       System.out.println(e);
/*    */     }
/*    */   }
/*    */ 
/*    */   public static void saveprops(String file, Properties p) {
/*    */     try {
/* 38 */       FileOutputStream out = new FileOutputStream(file);
/* 39 */       p.store(out, "/* properties updated */");
/*    */     }
/*    */     catch (Exception e) {
/* 42 */       System.out.println(e);
/*    */     }
/*    */   }
/*    */ 
/*    */   public static String convertDate(Date date, String format)
/*    */   {
/* 48 */     SimpleDateFormat sdf = new SimpleDateFormat(format);
/* 49 */     return sdf.format(date);
/*    */   }
/*    */ 
/*    */   public static Date convertLongToDate(String date)
/*    */   {
/* 54 */     String year = date.substring(0, 4);
/* 55 */     String month = date.substring(4, 6);
/* 56 */     String day = date.substring(6, 8);
/* 57 */     String hour = date.substring(8, 10);
/* 58 */     String minute = date.substring(10, 12);
/* 59 */     String second = date.substring(12, 14);
/*    */ 
/* 61 */     Calendar cal = Calendar.getInstance();
/* 62 */     cal.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day), 
/* 63 */       Integer.parseInt(hour), Integer.parseInt(minute), Integer.parseInt(second));
/* 64 */     return cal.getTime();
/*    */   }
/*    */ 
/*    */   public static Date convertLongToDate1(String date)
/*    */   {
/* 69 */     String year = date.substring(0, 4);
/* 70 */     String month = date.substring(4, 6);
/* 71 */     String day = date.substring(6, 8);
/*    */ 
/* 73 */     Calendar cal = Calendar.getInstance();
/* 74 */     cal.set(Integer.parseInt(year), Integer.parseInt(month) - 1, Integer.parseInt(day));
/* 75 */     return cal.getTime();
/*    */   }
/*    */ }

/* Location:           F:\16 2\SQ.jar
 * Qualified Name:     com.engine.Tools
 * JD-Core Version:    0.6.0
 */